package com.erp.action;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.erp.dto.Apply;

@Controller(value = "applyAction")
@Scope(value = "prototype")
public class ApplyAction extends ModelDrivenBaseAction<Apply> {

	private static final long serialVersionUID = 1L;
	
	private String procDefKey;// 流程定义Key

	public String getProcDefKey() {
		return procDefKey;
	}

	public void setProcDefKey(String procDefKey) {
		this.procDefKey = procDefKey;
	}

	/**
	 * 根据流程定义key进入相应的action
	 * 
	 * @param procDefKey
	 */
	public String addPage() {
		String actionName = procDefKey;
		return actionName + "_addPage";
	}

	/**
	 * 显示表单信息（转发给相应的action处理）
	 * 
	 * @return
	 */
	public String show() {
		// 获取申请表详情
		model = applyService.getById(model.getId());
		String procInstId = model.getProcInstId();
		// 获取action名称（即流程定义key）
		String actionName = workflowService.getProcDefKeyByProcInstId(procInstId);
		// 通过chain用request传递变量给下一个action
		request.put("apply", model);
		return actionName + "_show";
	}
}
